package com.prs.crm.dao.crm.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;


import com.prs.crm.dao.crm.CustomerProjectDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.crm.Customer;
import com.prs.crm.domain.crm.CustomerProject;
import com.prs.crm.domain.crm.DocumenTary;

public class CustomerProjectDaoImpl extends BaseDaoImpl<CustomerProject> implements CustomerProjectDao{

	@Override
	public List<CustomerProject> getProjectByCustomer(final Customer customer) {
		return (List<CustomerProject>) this.getHibernateTemplate().execute(new HibernateCallback() {
			@Override
			public Object doInHibernate(Session arg0)
					throws HibernateException, SQLException {
				Criteria criteria = arg0.createCriteria(CustomerProject.class);
				criteria.add(Restrictions.eq("customer", customer));
				return criteria.list();
			}
		});
	}
	
}
